#pragma once
#include <map>
#include <string>
#include <vector>
#include <iostream>
#include "TrTypes.h"



namespace TrBase
{
    std::string version();
    std::string AppPath();
    std::string AppPathin(const char* dir);
    uint64_t read_file_content(const char* filename, std::string& content);
    void write_file_content(const char* filename, const std::string& content);
    bool IsUTF8(const std::string& str);
    std::string StringToUTF8(const std::string& gbkData);
    std::string UTF8ToString(const std::string& utf8Data);
    bool loadContracts(ContractMap& map);
    bool loadCommodities(CommodityMap& map);
    bool loadConfigMap(StringMap& name, StringMap& session);

    namespace TrCommoditys
    {
        void insert(const Commodity& com);
        size_t count();
        CommodityMap Commoditys(const std::string& exchg = "all");
        double PriceTick(const std::string& code);
        std::string Session(const std::string& code);
        std::string Product(const std::string& code);
        std::string Exchg(const std::string& code);
        Commodity get(const std::string& code);
    }

    namespace TrContracts
    {
        void insert(const Contract& con);
        size_t count();
        ContractMap Contracts();
        Contract get(const std::string& code);
        uint32_t OpenDate(const std::string& code);
        uint32_t ExpireDate(const std::string& code);
        std::string Product(const std::string& code);
        std::string Exchg(const std::string& code);
        std::string Name(const std::string& code);
        int Multiple(const std::string& code);
        double strikePrice(const std::string& code);
        uint32_t maxMktQty(const std::string& code);
        uint32_t maxLmtQty(const std::string& code);
        uint32_t minMktQty(const std::string& code);
        uint32_t minLmtQty(const std::string& code);
    }
}

